package com.songlanyun.modules.sensitivelog.service.impl;

import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;

import com.songlanyun.modules.sensitivelog.dao.SensitiveLogDao;
import com.songlanyun.modules.sensitivelog.entity.SensitiveLog;
import com.songlanyun.modules.sensitivelog.service.SensitiveLogService;


@Service("sensitiveLogService")
public class SensitiveLogServiceImpl extends ServiceImpl<SensitiveLogDao, SensitiveLog> implements SensitiveLogService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String name = MapUtil.getStr(params, "name");
        IPage<SensitiveLog> page = this.page(
                new Query<SensitiveLog>().getPage(params),
                new LambdaQueryWrapper<SensitiveLog>()
                        .eq(StringUtils.isNotBlank(name), SensitiveLog::getName, name)
                        .orderByDesc(SensitiveLog::getCreateTime)
        );

        return new PageUtils(page);
    }

}